<template>
  <div class="artificialReplenishment">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">库存冻结</span>
        <el-button style="float: right;" type="primary" @click="dialogOpen()">新增</el-button>
      </div>
      <s-table
        :table="table"
        ref="table"
        @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableMultiPrint">多选打印</el-button>
            </el-col>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-row>
          <el-col :xs="24" :lg="{span: 4, offset: 0}">
            <el-form-item label="解冻人" prop="jdry">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_jdry"
                        placeholder="解冻人" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="冻结人" prop="cjry">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_cjry"
                        placeholder="冻结人" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="冻结单号" prop="djdh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_djdh"
                        placeholder="冻结单号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="冻结状态" prop="zt">
              <el-select v-model="autoVue_table_zt"
                         placeholder="冻结状态">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  v-for="item in STOCKFREEZING.zt"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 4, offset: 0}">
            <el-form-item label="创建时间" prop="cjsj">
              <el-date-picker
                v-model="autoVue_table_cjsj"
                type="daterange"
                placeholder="选择日期范围">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="解冻时间" prop="jdsj">
              <el-date-picker
                v-model="autoVue_table_jdsj"
                type="daterange"
                placeholder="选择日期范围">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="120">
          <template slot-scope="s">
            <el-button type="info" size="mini" @click="dialogThawOpen(s.row)" v-if="s.row.zt !== '2'">解冻</el-button>
            <!--
            <el-button type="info" size="mini" @click="tablePrint(s.row)"><i class="fa fa-print" aria-hidden="true"></i></el-button>
            -->
            <el-button type="info" size="mini" @click="tableExport(s.row)">导出</el-button>
          </template>
        </el-table-column>
      </s-table>
    </el-card>
    <s-dialog :dialog="dialog" :close="dialogInit">
      <p slot="title">{{dialog.title}}库存冻结</p>
      <s-form :form="formDialog" ref="formDialog">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="djdh" label="冻结单号">
              <el-input
                disabled
                type="text"
                v-model="formDialog.djdh"
                placeholder="冻结单号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="bz" label="备注">
              <el-input
                type="text"
                v-model="formDialog.bz"
                placeholder="备注"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <div class="__table">
        <el-button @click="dialogAddMxOpen('add')" class="__table_button"><i class="el-icon-plus"></i></el-button>
      </div>
      <s-table
        :table="tableAdd" ref="tableAdd" @http="tableWatch" :control="false">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="120">
          <template slot-scope="s">
            <!--<el-button type="info" icon="edit" size="mini" @click="tableEdit(s.row)"></el-button>-->
            <el-button type="info"  size="mini" @click="dialogEditOpen(s.row)">编辑</el-button>
            <!--前端删除：$index-->
            <el-button type="danger"  size="mini" @click="tableAddDelete(s.$index)">删除</el-button>
          </template>
        </el-table-column>
      </s-table>
      <el-button slot="footer" type="success"  @click="dialogSave">保存并冻结</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogAddMx" :close="dialogAddMxInit">
      <p slot="title">{{dialogAddMx.title}}库存冻结明细</p>
      <s-table :table="tableAddMx" ref="tableAddMx" @http="tableWatch" :multiSelect="true" >
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="库位名称" prop="kwmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_kwmc"
                    placeholder="库位名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品批次" prop="hppc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hppc"
                    placeholder="货品批次" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="生产日期" prop="scrq">
          <el-date-picker
            v-model="autoVue_tableAddMx_scrq"
            type="daterange"
            placeholder="选择日期范围">
          </el-date-picker>
        </el-form-item>
      </s-table>
      <el-button slot="footer" @click="dialogAddMxSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogThaw" :close="dialogThawInit">
      <p slot="title">{{dialogThaw.title}}库存<span>{{dialogThaw.row.djdh}}</span></p>
      <s-table :table="tableThaw" ref="tableThaw" @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="tableThaw.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="danger" @click="tableThawingStock('')">多选解冻</el-button>
            </el-col>
            <!--
            <el-col :span="8">
              <el-button size="small"  type="info" @click="tableConfirm('')">确认收货</el-button>
            </el-col>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
            -->
          </el-row>
        </el-form-item>
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="120">
          <template slot-scope="s">
            <el-button type="info" size="mini" @click="tableThawingStock(s.$index,s.row)">解冻库存</el-button>
            <!--
            <el-button type="info"  size="mini" @click="tableExport(s.row)">导出</el-button>
            -->
            <!--<el-button type="danger" icon="delete" size="mini" @click="tableDelete(s.row)"></el-button>-->
          </template>
        </el-table-column>
      </s-table>
    </s-dialog>
    <s-dialog :dialog="dialogEdit":close="dialogEditInit">
      <p slot="title">{{dialogEdit.title}}明细</p>
      <s-form :form="formDialogEdit" ref="formDialogEdit">
        <el-row>
          <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
            <el-form-item prop="hpbh" label="货品编号">
              <div class="s-content">{{formDialogEdit.hpbh}}</div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
            <el-form-item prop="hpmc" label="货品名称">
              <div class="s-content">{{formDialogEdit.hpmc}}</div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
            <el-form-item prop="hppc" label="货品批次">
              <div class="s-content">{{formDialogEdit.hppc}}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
            <el-form-item prop="kwmc" label="库位名称">
              <div class="s-content">{{formDialogEdit.kwmc}}</div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
            <el-form-item prop="scrq" label="生产日期">
              <div class="s-content">{{formatterTime(formDialogEdit.scrq)}}</div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
            <el-form-item prop="rksj" label="入库日期">
              <div class="s-content">{{formatterTime(formDialogEdit.rksj)}}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 7, offset: 0}" class="">
            <el-form-item prop="kdjsl" label="可冻结数量">
              <div class="s-content">{{formDialogEdit.kdjsl}}</div>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 7, offset: 1}" class="">
            <el-form-item prop="djsl" label="冻结数量">
              <el-input-number
                :min="0" :max="parseInt(formDialogEdit.kdjsl)"
                v-model="formDialogEdit.djsl"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogEditSave">保存</el-button>
    </s-dialog>
  </div>
</template>

<script>
  import {AutoVue} from '~/plugins/Tools';

  function __form () {
    return {
      djdh: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      bz: { value: '', rule: [ '' ], cRemarks: '' },
    };
  }
  function __formEdit () {
    return {
      hpbh: { value: '', rule: [], cRemarks: '' },
      hpmc: { value: '', rule: [], cRemarks: '' },
      hppc: { value: '', rule: [], cRemarks: '' },
      scrq: { value: '', rule: [], cRemarks: '' },
      sxrq: { value: '', rule: [], cRemarks: '' },
      rksj: { value: '', rule: [], cRemarks: '' },
      zxl: { value: '', rule: [], cRemarks: '' },
      dwms: { value: '', rule: [], cRemarks: '' },
      kwmc: { value: '', rule: [], cRemarks: '' },
      kdjsl: { value: '', rule: [], cRemarks: '' },
      djsl:
        { value: '',
          rule: [],
          cRemarks: '' },
    };
  }
  export default AutoVue({
    store: ['STOCKFREEZING', 'DICTIONARY_stockFreezing'],
    name: 'stock_stockFreezing-FEcarWms',
    head: {
      'title': '库存冻结管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 库存冻结 查看库存冻结信息' },
      ],
    },
    data: {
      table: {
        column:
          [
            { label: '冻结单号',
              prop: 'djdh',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '创建时间',
              prop: 'cjsj',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              type: 'DateRange',
              search: true },
            { label: '解冻时间',
              prop: 'jdsj',
              minWidth: '0px',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              type: 'DateRange',
              cRemarks: '',
              search: true },
            { label: '冻结人',
              prop: 'cjry',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '解冻人',
              prop: 'jdry',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '冻结状态',
              prop: 'show_zt',
              minWidth: '0px',
              cRemarks: '0未冻结 1已冻结',
              search: true },
          ],
        url: '/wmsstockfrozen/list',
        key: 'id',
        tableColumn: 6,
      },
      formDialog: __form(),
      dialog: {
        title: '新增',
        row: {},
        size: 'large',
        message: {},
      },
      tableAdd: {
        column:
          [ { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品批次',
            prop: 'hppc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '生产日期',
            prop: 'scrq',
            minWidth: '0px',
            cRemarks: '',
            type: 'dateRange',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '失效日期',
            prop: 'sxrq',
            minWidth: '0px',
            cRemarks: '',
            type: 'dateRange',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '入库日期',
            prop: 'rksj',
            minWidth: '0px',
            cRemarks: '',
            type: 'dateRange',
            formatter: (row, column) => {
              return this.a.methods.formatterTime(row[column.property || column], 3);
            },
            search: true },
          { label: '库位名称',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '可冻结数量',
            prop: 'kdjsl',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '冻结数量',
            prop: 'djsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          ],
        // url: '/wmsshipmentorder/getShipmentOrder',
        key: 'id',
        tableColumn: 9,
      },
      dialogAddMx: {
        title: '新增',
        size: 'large',
      },
      tableAddMx: {
        column:
          [
            { label: '货品编号',
              prop: 'hpbh',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '货品名称',
              prop: 'hpmc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '货品批次',
              prop: 'hppc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '生产日期',
              prop: 'scrq',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 3);
              },
              search: true },
            { label: '装箱量',
              prop: 'zxl',
              minWidth: '0px',
              cRemarks: '',
              search: false },
            { label: '单位描述',
              prop: 'dwms',
              minWidth: '0px',
              cRemarks: '',
              search: false },
            { label: '库位名称',
              prop: 'kwmc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '可用数量',
              prop: 'kdjsl',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '冻结数量',
              prop: 'djsl',
              minWidth: '0px',
              cRemarks: '',
              elInputNumber: {
                min: 1,
                controls: [false, true],
                max: 'kdjsl',
              },
              search: false },
            /*
            { label: '冻结数量',
              prop: 'djsl',
              minWidth: '0px',
              cRemarks: '',
              elInputNumber: {
                max: 'value',
                min: 1,
              },
              search: true },
              */
            { label: '失效日期',
              prop: 'sxrq',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              search: true },
            { label: '入库日期',
              prop: 'rksj',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              search: true },
          ],
        url: '/wmsstockfrozen/searchHp',
        tableColumn: 9,
        key: 'kcid',
        muti: false,
      },
      tableThaw: {
        column:
          [
            { label: '货品编号',
              prop: 'hpbh',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '货品名称',
              prop: 'hpmc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '货品批次',
              prop: 'hppc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '生产日期',
              prop: 'scrq',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 3);
              },
              search: true },
            { label: '装箱量',
              prop: 'zxl',
              minWidth: '0px',
              cRemarks: '',
              search: false },
            { label: '单位描述',
              prop: 'dwms',
              minWidth: '0px',
              cRemarks: '',
              search: false },
            { label: '可解冻数量',
              prop: 'djsl',
              minWidth: '0px',
              cRemarks: '',
              elInputNumber: {
                max: 'djsl',
                min: 1,
              },
              search: false },
            { label: '库位名称',
              prop: 'kwmc',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '可冻结数量',
              prop: 'kdjsl',
              minWidth: '0px',
              cRemarks: '',
              search: true } ],
        option: {
          id: '',
        },
        key: 'id',
        tableColumn: 7,
        url: '/wmsstockfrozen/searchFrozenMx',
      },
      dialogThaw: {
        title: '解冻',
        size: 'large',
        row: {},
      },
      dialogEdit: {
        title: '编辑',
        row: {},
      },
      formDialogEdit: __formEdit(),
    },
    transition: 'slide-fade',
    methods: {
      tableExport (row) {
        let tableRef = 'table';

        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将导出库存冻结。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/wmsstockfrozen/exportWmsStockFrozen',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableConfirm (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将进行确认补货的操作', '确认补货？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsorderrepair/confirmOrder', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableDelete (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将删除选择的数据', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsorderrepair/delete', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      dialogInit () {
        this.formDialog = {
          ...this.formDialog,
          ...this.ObjectClone(__form()),
        };
        this.tableClear('tableAdd');
      },
      async dialogOpen () {
        /* 取后台这样的值：{djdh: "201803191"}
        */
        let bh = await this.post('/wmsstockfrozen/searchDjdh');
        this.formDialog.djdh = bh.djdh;
        this.dialog.visible = true;
      },
      dialogSave () {
        this.VALIDATE('formDialog', async option => {
          let step = [];
          this.tableAdd.data.forEach(item => {
            let option = Object.assign({}, item);
            if (option.djsl === 0) {
              // delete option.row;
              // delete option.djsl;
            }
            step.push(option);
          });
          let json = {
            ...option,
            list: step,
          };
          try {
            await this.post('/wmsstockfrozen/add', json);
            this.tableWatch('table');
            this.dialogInit();
            this.dialog.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
        /*
        this.VALIDATE('formDialog', async option => {
          let step = [];
          this.tableAdd.data.forEach(item => {
            let option = Object.assign({}, item);
            delete option.scrq;
            delete option.sxrq;
            delete option.rksj;
            for (let index in option) {
            // hasOwnProperty() 方法会返回一个布尔值，指示对象自身属性中是否具有指定的属性
              if (option.hasOwnProperty(index)) {
                if (!option[index]) {
                  delete option[index];
                }
              }
            }
            step.push(option);
          });
          let json = {
            ...this.FORMOPTION('formDialog'),
            ...option,
            list: step,
          };
          try {
            await this.post('/wmsstockfrozen/add', json);
            this.tableWatch('table');
            this.dialogInit();
            this.dialog.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
        */
      },
      tableAddMxEdit (row) {
        this.dialogAddMxOpen('PUT', row);
      },
      tableAddDelete (index) {
        this.$confirm('您将删除选择的明细货品编号为:', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(_ => {
            this.tableAdd.data.splice(index, 1);
          });
      },
      tableEdit (row) {
        this.dialogAddMxOpen('PUT', row);
      },
      dialogAddMxInit () {
        this.tableClear('tableAddMx');
      },
      dialogAddMxOpen (type, more) {
        if (type) {
          type = type.toUpperCase();
        } else return;
        switch (type) {
        case 'ADD':
          this.dialogAddMx.title = '新增';
          break;
        case 'PUT':
          this.dialogAddMx.title = '修改';
          /*
            let step = [];
            // this.tableAddMx.multipleSelection
            this.tableAdd.data.forEach(item => {
              step.push(item);
            });
            this.tableAddMx.data = step;
            */
          break;
        }
        if (this.dialogAddMx.title === '新增') {
          this.tableAddMx.url = '/wmsstockfrozen/searchHp';
          this.tableWatch('tableAddMx');
        }
        this.dialogAddMx.visible = true;
      },
      dialogAddMxSave () {
        if (this.dialogAddMx.title === '新增') {
          if (this.tableAddMx.multipleSelection.length < 1) {
            this.$alert('请至少选择1条货品信息', '提示');
          } else {
            this.tableAddMx.data = [
              ...this.tableAdd.data,
              // 截取列表中选择的的内容
              ...this.tableAddMx.multipleSelection,
            ];
            // 遍历
            this.tableAddMx.multipleSelection.forEach(item => {
              // push() 方法可向数组的末尾添加一个或多个元素，并返回新的长度。
              this.tableAdd.data.push(item);
            });
            this.dialogAddMxInit();
            this.dialogAddMx.visible = false;
          }
        } else if (this.dialogAddMx.title === '修改') {
          this.dialogAddMx.visible = false;
        }
      },
      dialogThawOpen (row) {
        this.dialogThaw.row = row;
        if (this.dialogThaw.title === '解冻') {
          this.tableThaw.option.id = row.id;
          this.tableThaw.url = '/wmsstockfrozen/searchFrozenMx';
          this.tableWatch('tableThaw');
        }
        this.dialogThaw.visible = true;
      },
      tableThawingStock (index, row) {
        let ids = [];
        if (row) {
          ids.push({kdjsl: row.djsl.toString(), id: row.id});
        } else {
          if (this.tableThaw.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.tableThaw.multipleSelection.forEach(item => {
            ids.push({kdjsl: row.djsl, id: item.id});
          });
        }
        this.$confirm('您将解冻选择的数据', '确认解冻？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsstockfrozen/stockThaw', {
                id: this.tableThaw.option.id,
                list: ids,
              });
              this.tableThaw.url = '/wmsstockfrozen/searchFrozenMx';
              this.tableWatch('tableThaw');
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      dialogThawInit () {
        this.tableClear('tableThaw');
      },
      dialogEditInit () {},
      dialogEditOpen (row) {
        this.formDialogEdit = {
          ...this.formDialogEdit,
          ...this.ObjectClone(__formEdit(), row),
        };
        this.dialogEdit.row = row;
        console.log('this.dialogEdit.row:' + this.dialogEdit.row);
        this.dialogEdit.visible = true;
      },
      dialogEditSave () {
        this.VALIDATE('formDialogEdit', async option => {
          for (let index in option) {
            if (option.hasOwnProperty(index)) {
              if (!option[index]) continue;
              this.dialogEdit.row[index] = option[index];
            }
          }
          this.dialogEditInit();
          this.dialogEdit.visible = false;
        });
      },
    },
    mounted: async function () {
      console.log('stockfreezing.vue');
      this.tableWatch('table');
      if (!this.DICTIONARY_stockFreezing) {
        await this.USE('DICTIONARY_stockFreezing');
      }
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
  .artificialReplenishment{
    width: 88vw;
    float: left;
  }
</style>
